#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <left4dhooks>

#define PLUGIN_NAME "L4D2_OnStagger"
#define PLUGIN_AUTHOR "豆瓣酱な"
#define PLUGIN_DESCRIPTION "取消boomer死亡爆炸对玩家和特感方的硬直效果."
#define PLUGIN_VERSION "1.0"
#define PLUGIN_URL "https://gitee.com/sweet-and-sour-bombs"

public Plugin myinfo =
{
	name = PLUGIN_NAME,
	author = PLUGIN_AUTHOR,
	description = PLUGIN_DESCRIPTION,
	version = PLUGIN_VERSION,
	url = PLUGIN_URL
}

public Action L4D2_OnStagger(int target, int source)
{
	// 只处理生还者和特感
	if(GetClientTeam(target) == 2 || GetClientTeam(target) == 3)
	{
		// 检查击退来源是否是Boomer
		if(IsValidClient(source) && GetEntProp(source, Prop_Send, "m_zombieClass") == 2)
		{
			// 检查是否是死亡爆炸造成的击退
			if(!IsPlayerAlive(source))
			{
				return Plugin_Handled;
			}
		}
	}
	return Plugin_Continue;
}

bool IsValidClient(int client)
{
	return client > 0 && client <= MaxClients && IsClientInGame(client);
}
